package io.renren.config;

import io.renren.modules.oss.cloud.CloudStorageConfig;
import lombok.Getter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/**
 * @author: xiaomi
 * @date: 2022/2/15
 * @description:
 */
@Component
public class TXYCosConfig {

    @Value("${tengxun.qcloudDomain}")
    private String qcloudDomain;
    @Value("${tengxun.qcloudPrefix}")
    private String qcloudPrefix;
    @Value("${tengxun.qcloudAppId}")
    private String qcloudAppId;
    @Value("${tengxun.qcloudSecretId}")
    private String qcloudSecretId;
    @Value("${tengxun.qcloudSecretKey}")
    private String qcloudSecretKey;
    @Value("${tengxun.qcloudBucketName}")
    private String qcloudBucketName;
    @Value("${tengxun.qcloudRegion}")
    private String qcloudRegion;

    @Getter
    private CloudStorageConfig cConfig;

    @PostConstruct
    public void initConfig() {
        cConfig = new CloudStorageConfig();
        cConfig.setQcloudDomain(qcloudDomain);
        cConfig.setQcloudPrefix(qcloudPrefix);
        cConfig.setQcloudAppId(Integer.parseInt(qcloudAppId));
        cConfig.setQcloudSecretId(qcloudSecretId);
        cConfig.setQcloudSecretKey(qcloudSecretKey);
        cConfig.setQcloudBucketName(qcloudBucketName);
        cConfig.setQcloudRegion(qcloudRegion);
    }
}
